package Collection;

import java.util.ArrayList;
import java.util.TreeSet;

/**
 * @author wuhan
 * @date 2019/9/26 16:37
 */
public class GenericDemo {
    public static void main(String[] args) {
//        ArrayList<Student> arrayList = new ArrayList<>();
//        arrayList.add(new Student("wuhan",100));
//        for (Student student : arrayList) {
//            System.out.println(student.getName()+"  "+student.getAge());
//        }
//        TreeSet<String> ts=new TreeSet<>();
        Utils<Worker> utils=new Utils<>();
        utils.setT(new Worker());
        Worker w = utils.getT();
    }
}

//class Tool{
//    private Object obj;
//
//    public Object getObj() {
//        return obj;
//    }
//
//    public void setObj(Object obj) {
//        this.obj = obj;
//    }
//}泛型前做法

class Utils <T>{
    private T t;

    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }
}

class Worker{
    Worker() {

    }

    public Worker(String name) {
        this.name = name;
    }

    private String name;
    private int agr;

    public Worker(String name, int agr) {
        this.name = name;
        this.agr = agr;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAgr() {
        return agr;
    }

    public void setAgr(int agr) {
        this.agr = agr;
    }
}

